package ru.madeira.jtetris;

import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;

public class ImageHolder {
    public static final int MAX_PICTURES = 4;
    public static final int IMG_BACKGROUND = 0;
    public static final int IMG_BRICK = 1;
    public static final int IMG_LEVEL = 2;
    public static final int IMG_LOSE = 3;
    public static Image[] IMAGELIST;

    static{
        IMAGELIST = new Image[MAX_PICTURES];
        Image main_image = Toolkit.getDefaultToolkit().getImage("res/tileset.png");
        CropImageFilter crp = new CropImageFilter(0,0,500,300);
        Image buf = Toolkit.getDefaultToolkit().createImage(new FilteredImageSource(main_image.getSource(), crp));
        ReplicateScaleFilter rsf = new ReplicateScaleFilter(Field.FIELD_WIDTH * GUIManager.TILE_SIZE,
                Field.FIELD_HEIGHT * GUIManager.TILE_SIZE);
        IMAGELIST[IMG_BACKGROUND] = Toolkit.getDefaultToolkit().createImage(new FilteredImageSource(buf.getSource(), rsf));
        crp = new CropImageFilter(0,300,64,64);
        buf = Toolkit.getDefaultToolkit().createImage(new FilteredImageSource(main_image.getSource(), crp));
        rsf = new ReplicateScaleFilter(GUIManager.TILE_SIZE,
                GUIManager.TILE_SIZE);
        IMAGELIST[IMG_BRICK] = Toolkit.getDefaultToolkit().createImage(new FilteredImageSource(buf.getSource(), rsf));
        crp = new CropImageFilter(0,364,200,125);
        buf = Toolkit.getDefaultToolkit().createImage(new FilteredImageSource(main_image.getSource(), crp));
        IMAGELIST[IMG_LEVEL] = Toolkit.getDefaultToolkit().createImage(new FilteredImageSource(buf.getSource(), rsf));
        crp = new CropImageFilter(200,364,200,110);
        buf = Toolkit.getDefaultToolkit().createImage(new FilteredImageSource(main_image.getSource(), crp));
        IMAGELIST[IMG_LEVEL] = Toolkit.getDefaultToolkit().createImage(new FilteredImageSource(buf.getSource(), rsf));

    }

}
